import java.util.Arrays;

public class test4 {

    //力扣 15 三数之和
    public static void main(String[] args) {
        int[] nums = {0, 0, 0};
        int max = nums.length - 1;
        Arrays.sort(nums);
        int[][] arr = new int[8][3];
        int i = 0;
        while (max >= 2 && nums[max] >= 0) {

            int left = 0;
            int right = max - 1;

            while (left < right) {

                if (nums[left] + nums[right] + nums[max] > 0) {
                    right--;
                    while (nums[right - 1] == nums[right] && left < right) {
                        right--;
                    }


                } else if (nums[left] + nums[right] + nums[max] < 0) {
                    left++;
                    while (nums[left + 1] == nums[left] && left < right) {
                        left++;
                    }
                } else {
                    arr[i][0] = nums[left];
                    arr[i][1] = nums[right];
                    arr[i][2] = nums[max];
                    i++;
//                    System.out.println(nums[left]+" "+nums[right]+" "+nums[max]);
                    left++;
                    while (nums[left + 1] == nums[left] && left < right && left < nums.length - 1) {
                        left++;
                    }
                    right--;
                    while (nums[right - 1] == nums[right] && left < right && right > 0) {
                        right--;
                    }
                }
            }

            max--;
            while (nums[max--] == nums[max] && max >= 2 && nums[max] >= 0) {
                max--;
            }
        }

        for (int i1 = 0; i1 < arr.length; i1++) {
            for (int i2 = 0; i2 < arr[i2].length; i2++) {
                System.out.print(arr[i1][i2] + " ");
            }
            System.out.println();
        }
    }

}
